-
Notifications
You must be signed in to change notification settings - Fork 895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import history, bookmarks, cookies, and passwords from Brave #185
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good just few places require changes. I'm still looking at the BraveImporter::ImportBookmarks
but in the meanwhile you can address the comments
@@ -73,36 +75,61 @@ index 3bf47fa746e2a417f89201f3e3800d8639f2e323..122e9daf552834db4d41c77a32033230 | |||
+ AddChromeToProfiles(profiles, chromium_profiles, chromium_user_data_folder, | |||
+ brandChromium); | |||
+} | |||
+ | |||
+void DetectBraveProfiles(std::vector<importer::SourceProfile>* profiles) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking maybe we can put DetectBraveProfiles
, DetectChromeProfiles
and AddChromeToProfiles
into
chromium_src/chrome/browser/importer/importer_list.cc
The patch is kind of bloated now
|
||
TEST_UDD=/path/to/test/user/data/dir | ||
mkdir -p $TEST_UDD | ||
CHROME_USER_DATA_DIR=$TEST_UDD /Applications/Brave.app/Contents/MacOS/Brave |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usual way we use is /Applications/Brave.app/Contents/MacOS/Brave --user-data-dir-name=$TEST_UDD
in muon based Brave (https://github.com/brave/muon/blob/tor_browser_context/atom/common/options_switches.cc#L34) or there will be some collision for crash reporter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know! I didn't know it was also a command line flag, will test again to verify that it works and update these docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darkdh As I recall now, I did try to use --user-data-dir-name
at first, but unfortunately it does not seem to work as intended. It causes Brave to start with a fresh profile, but that profile's data never gets saved in the specified user data directory. After quitting Brave, the specified user data directory is empty. This does not happen when I use CHROME_USER_DATA_DIR
. Saving the temporary state to disk is critical for my use case, since I need to extract the relevant Brave state files to use for test data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that sounds like a bug in muon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darkdh Upon further testing, it looks like --user-data-dir
has the expected behavior, while --user-data-dir-name
does not. --user-data-dir
is a Chromium flag, I'm not sure but it seems --user-data-dir-name
might have been introduced in Muon. Should I update the documentation to recommend --user-data-dir
instead of CHROME_USER_DATA_DIR
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, please. thanks
utility/importer/brave_importer.h
Outdated
#include "chrome/common/importer/imported_bookmark_entry.h" | ||
#include "chrome/utility/importer/importer.h" | ||
|
||
class BraveImporter : public Importer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should inherit ChromeImporter and make Import*
virtual functions so that we don't have to duplicate codes for ImportPasswords
and ImportCookies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm with you in spirit, and will give this a shot, but in my experience there are unfortunately some minor differences between how Chromium and Brave end up storing data which makes it tricky to simply reuse the code from ChromeImporter. However, I believe some of these are probably easy to resolve and others should be resolved in browser-laptop rather than worked around in brave-core. I will give this a shot and file follow-ups as I go.
great work on |
|
||
#include "base/bind.h" | ||
#include "base/strings/string_number_conversions.h" | ||
+#include "brave/grit/generated_resources.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase to master. We don't need to patch this now,
see 5b4838a
+#include "brave/common/importer/chrome_importer_utils.h" | ||
+#include "brave/grit/generated_resources.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@darkdh Ready for re-review |
lgtm, would you mind doing a rebase? it shows conflict against master. |
@darkdh Rebased! |
utility/importer/brave_importer.cc
Outdated
} | ||
} | ||
#else | ||
base::FilePath prefs_path = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually can we pass as argument? since it is the only deviation compared to ChromeImporter:: ImportPasswords
so that we don't have to override it
@@ -1,5 +1,5 @@ | |||
diff --git a/chrome/browser/ui/content_settings/content_setting_image_model.cc b/chrome/browser/ui/content_settings/content_setting_image_model.cc | |||
index 366ba05a508c8e5f77bd0a380ff229da73065819..b24ef19f81ab2c469780caab71a5953d95750d16 100644 | |||
index 366ba05a508c8e5f77bd0a380ff229da73065819..4f159eee09eb691c796681af5e669df442aca7b7 100644 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this patch seems irrelevant to this PR
@@ -19,7 +19,7 @@ index 1cbcc2fcb663c43daad9e6ad86f97e74b964aa11..2910707b7f569cb87947c81d8522f1d9 | |||
#include "base/threading/thread.h" | |||
#include "base/threading/thread_task_runner_handle.h" | |||
#include "build/build_config.h" | |||
@@ -39,6 +43,16 @@ void ProfileImportImpl::StartImport( | |||
@@ -39,6 +43,19 @@ void ProfileImportImpl::StartImport( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we subclass ProfileImportImpl
and only overrides StartImport
?
In overridden method do OSCrypt password hack first and then call parent's StartImport
so we only need to substitute ProfileImportImpl
to BraveProfileImportImpl
by preprocessor in chrome/utility/importer/profile_import_service.cc
with only one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one unrelated request but it will allow us to remove this patch completely
can we use preprocessor for BraveExternalProcessImporterBridge
?
|
||
std::string password; | ||
gchar* password_c = nullptr; | ||
+ const char* application_name; | ||
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | ||
+ if (command_line->HasSwitch("import-chrome")) { | ||
+ application_name = "chrome"; | ||
+ } else if (command_line->HasSwitch("import-chromium")) { | ||
+ } else if (command_line->HasSwitch("import-chromium") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use preprocessor to get rid of this patch too
@@ -19,7 +19,8 @@ index aa4b3d4a6b5c7b1f725d6446ea5e573094ec935b..4c4c7191a57afc7a42dfa87701578bd9 | |||
+ if (command_line->HasSwitch("import-chrome")) { | |||
+ folder_name = "Chrome Keys"; | |||
+ key = "Chrome Safe Storage"; | |||
+ } else if (command_line->HasSwitch("import-chromium")) { | |||
+ } else if (command_line->HasSwitch("import-chromium") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -28,7 +28,8 @@ index a1b5b975bc89c4891643adab17ce0b00ba2a8032..9d4be365463d2555101a96006ca4c68a | |||
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |||
+ if (command_line->HasSwitch("import-chrome")) { | |||
+ application_name = "chrome"; | |||
+ } else if (command_line->HasSwitch("import-chromium")) { | |||
+ } else if (command_line->HasSwitch("import-chromium") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -26,7 +26,8 @@ index 2b38db266f9aa1f4141c8649c021042ede4e5589..4b14f15e5091b251be53eff29139beaa | |||
+ if (command_line->HasSwitch("import-chrome")) { | |||
+ service_name = "Chrome Safe Storage"; | |||
+ account_name = "Chrome"; | |||
+ } else if (command_line->HasSwitch("import-chromium")) { | |||
+ } else if (command_line->HasSwitch("import-chromium") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can do the eliminating patches task in follow up
@garrettr could you open an issue for follow up? Thanks. |
WHOOOOOHOOOO 🎉 |
Toggle Tweak & Alignment Tweak
Partially resolves brave/brave-browser#24.
Resolves brave/brave-browser#220.
Since Brave browser-laptop is also based on Chromium (via Electron/Muon), some (but not all) user data is stored in an identical or mostly identical manner as it is in Chrome/Chromium; therefore, the corresponding import methods are based on, and similar (but not identical) to those for
ChromeImporter
, including:ImportHistory
,ImportCookies
,ImportPasswords
.ImportBookmarks
was completely rewritten because browser-laptop stores bookmarks in a location and with a data structure that are totally different from Chromium's. However, it still uses the same high-level approach asChromeImporter::ImportBookmarks
—an in-order traversal of the bookmarks tree, because that's whatAddBookmarks
requires in order to maintain the relative order of the bookmarks once imported.Some work is intentionally being left for follow-up issues (which I will file soon), including:
ChromeProfileLock
BraveImporter::ImportFavicons
. Importing favicons from Brave is more complicated than it was for Chrome because Brave stores favicons in the cache along with all the other web content.This PR also fixes some minor issues in
ChromeImporter
that were discovered during the development process.Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
yarn start
. Go to the Brave menu and choose Import Bookmarks and Settings. Choose a Brave profile to import. Check Bookmarks, History, Cookies and Passwords to verify that they were imported correctly.yarn test brave_unit_tests
. AllBraveImporterTest.*
should pass.This PR has been successfully manually tested on macOS, Windows 10, and Linux (Ubuntu 16.04, Brave installed via Debian package).
There are known issues with importing cookies and passwords from Brave when installed on Linux via Snapcraft which will have to be addressed in a follow-up.
Reviewer Checklist: